<?php
/**
 * Created by PhpStorm.
 * User: wangan
 * Date: 2017/4/16
 * Time: 11:57
 */

namespace App\Http\Service;

use App\Models\Questions;

class QuestionsService
{


    /*
     * @param $int_type 题目类型
     * @desc 获取分页列表
     * */
    public static function getQuestionListPageInit($int_type = 0){
        $enity_question = Questions::orderBy('id','desc');
        if ($int_type){
            $enity_question->where('type',$int_type);
        }
        return $enity_question->paginate(20);
    }

    /*
     * @desc 获取所有题目类型
     * */
    public static function getTypes(){
        return Questions::types();
    }

    public static function createOneQuestion($arr_info){
        return Questions::create($arr_info);
    }

    public static function deleteQuestions($arr_questionIds){
        return (Questions::whereIn('id',$arr_questionIds)
            ->update([
            'isdelete' => 1
        ]));
    }

    public static function getOneQuestionInfo($int_questionId){
        return Questions::find($int_questionId);
    }

    public static function editQuestion($arr_info){
        return Questions::where('id',$arr_info['id'])
            ->update($arr_info);
    }


}